/**********************************************************************
* Filename: Treinador.java
* Created: 2012/04/23
* @author Fernando Brito e Abreu
**********************************************************************/
package org.mgaiao.copaPaises.businessLayer;

import java.util.Set;
import java.util.HashSet;

public class Treinador extends Participante
{
	public static Set<Treinador> allInstances = new HashSet<Treinador>();
	
	
	/**********************************************************************
	* Default constructor
	**********************************************************************/
	public Treinador()
	{
		super();
		allInstances.add(this);
	}
	
	/**********************************************************************
	* Parameterized constructor
	* @param data_nascimento the data_nascimento to initialize (inherited)
	* @param nome the nome to initialize (inherited)
	* @param nacionalidade the nacionalidade to initialize (inherited)
	**********************************************************************/
	public Treinador(CalendarDate data_nascimento, String nome, Pais nacionalidade)
	{
		super(data_nascimento, nome, nacionalidade);
		allInstances.add(this);
	}
	
	/**********************************************************************
	* ONE2MANY getter for Treinador[1] <-> Participacao[*]
	* @return the participacoes of the treinador
	**********************************************************************/
	public Set<Participacao> participacoes()
	{
		Set<Participacao> result = new HashSet<Participacao>();
		for (Participacao x : Participacao.allInstances)
			if (x.treinador()  ==  this)
				result.add(x);
		return result;
	}
	
	/**********************************************************************
	* ONE2MANY setter for Treinador[1] <-> Participacao[*]
	* @param participacoes the participacoes to set
	**********************************************************************/
	public void setParticipacoes(Set<Participacao> participacoes)
	{
		for (Participacao x : participacoes)
			x.setTreinador(this);
	}
	
	/* (non-Javadoc)
	* @see java.lang.Object#toString()
	*/
	@Override
	/**********************************************************************
	* Object serializer
	**********************************************************************/
	public String toString()
	{
		return "Treinador []\n";
	}
	
}
